package com.ls.rbac.exception;

import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * created by liush on 2025/6/28
 **/

@RestControllerAdvice
@Slf4j
public class GlobalException {  //全局异常处理

    @ExceptionHandler(Exception.class)
    public ResponseEntity<String> exceptionHandler(Exception e) {
        log.error("全局异常捕获:{}", e.getMessage());
        e.printStackTrace();
        return ResponseEntity.status(500).body("服务器异常:"+e.getLocalizedMessage());
    }

}
